package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	EmpEventNew          = "mes.EmpNew"
	EmpEventBeforeCreate = "mes.EmpBeforeCreate"
	EmpEventBeforeUpdate = "mes.EmpBeforeUpdate"
	EmpEventBeforeSave   = "mes.EmpBeforeCreate mes.EmpBeforeUpdate"
	EmpEventAfterCreate  = "mes.EmpAfterCreate"
	EmpEventAfterUpdate  = "mes.EmpAfterUpdate"
	EmpEventAfterSave    = "mes.EmpAfterCreate mes.EmpAfterUpdate"
	EmpEventDelete       = "mes.EmpDelete"

	EmpAccessControlEvent = "mes.EmpAccessControl"
)

func GetEmpConfig() *mgo.DocConfig {
	return Emp_Config
}

var Emp_Config *mgo.DocConfig

func init() {
	Emp_Config = NewEmpConfig()
}

func NewEmpConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "mes.Emp",
		Fields: []string{
			"name", "sn", "card", "department", "role", "password", "status", "lastLogin", "lastLoginIp",
		},
		RelationFields: []string{
			"department",
		},
		RelationConfigs: map[string]*mgo.DocRelation{

			"department": {
				Config:     GetDepartmentConfig,
				DocName:    "Department",
				JoinType:   "O",
				KeyInside:  "departmentId",
				KeyOutSide: "id",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
